import time

from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy
from appium.webdriver.common.touch_action import TouchAction

url = "http://127.0.0.1:4723/wd/hub"

param = {
    "deviceName": "6f3d92e1",  # 设备号
    "platformName": "Android",  # 系统名称
    "platformVersion": "13",  # 系统版本
    "appPackage": "com.chinamworld.main",  # 软件包名
    "appActivity": "com.ccb.start.MainActivity"  # 启动类名
}

driver = webdriver.Remote(url, param)

# el1 = driver.find_element(MobileBy.XPATH,"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.slidingpanelayout.widget.SlidingPaneLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.widget.FrameLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.webkit.WebView/android.webkit.WebView/android.view.View/android.view.View/android.view.View[1]/android.view.View/android.view.View[2]/android.view.View/android.view.View[1]/android.view.View/android.view.View[4]/android.widget.Image")
# el1.click()
el1 = driver.find_element(MobileBy.ACCESSIBILITY_ID,"同意")
el1.click()
time.sleep(5)
TouchAction(driver).tap(x=1281, y=408).perform()
time.sleep(3)



TouchAction(driver).tap(x=492, y=215).perform()
el2 = driver.find_element(MobileBy.ACCESSIBILITY_ID,"拒绝")
el2.click()
time.sleep(4)
el3 = driver.find_element(MobileBy.ID,"com.chinamworld.main:id/search_edit")
el3.send_keys("零存整取")
time.sleep(4)
el4 = driver.find_element(MobileBy.ACCESSIBILITY_ID,"搜索")
el4.click()
time.sleep(4)
el5 = driver.find_element(MobileBy.ID,"com.chinamworld.main:id/suggestion1_text")
el5.click()
time.sleep(45)

el6 = driver.find_element(MobileBy.XPATH,"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View/android.view.View/android.view.View[3]/android.widget.TextView")
el6.click()
time.sleep(4)
el7 = driver.find_element(MobileBy.ID,"com.chinamworld.main:id/rl_transfer_type")
el7.click()
time.sleep(4)
el8 = driver.find_element(MobileBy.ACCESSIBILITY_ID,"开户")
el8.click()
time.sleep(4)
el9 = driver.find_element(MobileBy.ID,"com.chinamworld.main:id/rl_period")
el9.click()
time.sleep(4)
e20 = driver.find_element(MobileBy.ACCESSIBILITY_ID,"一年")
e20.click()
time.sleep(4)
e21 = driver.find_element(MobileBy.ID,"com.chinamworld.main:id/et_transfer_amount")
e21.click()
time.sleep(4)
e22 = driver.find_element(MobileBy.ID,"com.chinamworld.main:id/et_transfer_amount")
e22.send_keys("5")
driver.quit()